<?php
include_once('inc/init.php');
include_once('inc/functions.index.php');
?>
<?php
// Define some variables.
$error_msg = "";
$email = "";
$email = stripslashes($_REQUEST['email']);
$reset = false;
$lost_pass_key = "";
$invalid = false;

// Verify url email and key.
$lost_pass_key = stripslashes($_REQUEST['email']);
if (strlen($lost_pass_key) > 0 && strlen($email) > 0) {
	$sql_cmd = "select * from users where lost_pass_key= '$lost_pass_key' AND email = '$email'";
	$sql_query = mysql_query($sql_cmd) or die(mysql_error());
	if (mysql_num_rows($sql_query)<1) {
			$invalid = true;
	}
} else {
	$invalid = true;
}

// Verify if the form was sent.
if (isset($_REQUEST['action']) && !$invalid) {
	$email = stripslashes($_REQUEST['email']);	
	if (strlen($email)==0) {
		$error_msg .= "<p> '<strong>Your e-mail address</strong>' field is empty. </p>";
	}else{
		//$error_msg = Recover_password($email);
	}
}

?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>New Password - The Finger For</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<?php include_once('template/head.php');?> 
</head>

<body>
	<div id="wrap">
		<!-- header -->
		<?php include_once('template/header.php'); ?>
		<!-- body -->
		<div id="body">
			<?php include_once('template/subheader.php'); ?>
			<h1>Set New Password</h1>
			<div class="body">
			
			<?php 
			if ($invalid): ?>
				<div class="error">
					<p>Invalid reset password link.</p>
				</div>
			<?php elseif($reset): ?>
				<p class="form_item">
					Your password has been changed, you can <a href="<?php echo BASE_URL; ?>login.php">login</a> now.
				</p>
			<?php else: ?>
				<?php if (strlen($error_msg)>0) { ?>
					<div class="error">
						<?php echo $error_msg; ?>
					</div>
				<?php } ?>			
				<form name="login" action="<?php echo $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];?>" method="post">
					<p class="form_item">
						<span class="label"> Your new password: </span>
						<span class="desc"> Please enter new password. </span>
						<input type="hidden" name="action" value="recover" />
						<input type="password" name="password" class="inputwb wide3x" />
					</p>
					<p class="form_item">
						<span class="label"> Repeat new password: </span>
						<span class="desc"> Please enter your password again. </span>
						<input type="password" name="password2" class="inputwb wide3x" />
					</p>					
					<p class="form_item">
						<span class="desc">Set pasword!</span>
						<input type="submit" class="dark_btn" value="Accept" />
					</p>
				</form>
			<?php endif; ?>
				</div>
		</div>
		<!-- footer -->
		<?php include_once('template/footer.php'); ?>
	</div>
	<br /><br /> <!-- keep some space with the bottom -->
</body>
</html>
<?php mysql_close($db); ?>